Add single database configuration section#276
Conversation
Similar to solid_queue, this documents how to configure Solid Cache to use a single database instead of separate databases for the app and cache.
|
@trevorturk - if we use the same database for the cache, I think we'd still want to use a separate connection pool, otherwise cache writes get tied up in app transactions. This could have unintended consequences like deadlocks or rollbacks undoing cache writes. We could configure the app so that we have two connection pools that both point to the same database, something like: production:
primary: &primary_production
<<: *default
database: app_production
username: app
password: <%= ENV["APP_DATABASE_PASSWORD"] %>
cache:
<<: *primary_production
database_tasks: falseHowever this is something we definitely wouldn't want to do with SQLite as only a single write transaction can be open at a time and separate connection pools to the same database could block each other. For SQLite I would always recommend a separate database. |
|
Ah interesting points, I hadn't considered. I'm mainly looking to have simple starter Rails apps up and running on Heroku, Render, etc with the Solid stack to keep the dependencies and services to a minimum. I'm not sure if you want to consider writing more documentation considering the details and caveats you mention here, and just close this? I could also take a shot at updating this PR if you'd like. No worries here, really, thanks for the review! |
|
@trevorturk - yes I can do that. I'll keep this PR open as a reminder though! |
Ref: rails/solid_queue#334
This adds a "Single database configuration" section to the README, similar to what exists in solid_queue. While running Solid Cache in a separate database is recommended for production use, this documentation helps users who want to use a single database for simplicity or in development environments.
FWIW I'd advocate for
rails newto default to using a single database for the Solid stuff, but I think that ship has already sailed... ⛵ 👋 🤣